import axios from '@/lib/script/http'

const getBaseUrl = () => {
  return ''
}

// 新增应用
export const postAppInfo = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/application/`,
      method: 'POST',
      data: args,
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}

// 查询应用列表
export const getAppList = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/application/`,
      method: 'GET',
      params: args
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}

// 查询单个应用
export const getAppInfo = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/application/${args.id}`,
      method: 'GET',
      params: args
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}

// 跟新应用信息
export const updateAppInfo = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/application/${args.id}`,
      method: 'PUT',
      data: args
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}

// 删除应用
export const delAppInfo = (args: any) => {
  return new Promise((resolve, reject) => {
    axios({
      url: getBaseUrl() + `/application/${args.id}`,
      method: 'DELETE',
      data: args
    }).then((resp: any) => {
      resolve(resp)
    }, reject)
  })
}